package com.cskaoyan.javase.network._2tcp._v4;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端
 * 服务端接收客户端传输的对象二进制数据,反序列化成一个对象
 *
 * @since 16:24
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Server {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ServerSocket serverSocket = new ServerSocket(11111);
        Socket socket = serverSocket.accept();
        // 获取socket的输入流,读取客户端发送的对象二进制数据
        // 这时需要进行反序列化操作
        // 字节输入流 --> 对象字节输入流
        ObjectInputStream objOut = new ObjectInputStream(socket.getInputStream());
        Student student = (Student) objOut.readObject();
        System.out.println(student);

        serverSocket.close();

    }
}
